<template>
  <div>
    <form @submit.prevent="fn">
      <label>姓名：</label>
      <input type="text"  v-model.lazy="name" /><br /><br />

      <label>年龄：</label>
      <input type="number" v-model.lazy="age" /><br /><br />

      <label>身高：</label>
      <input type="text" v-model.number="hight" />(米)<br /><br />

      <label>体重：</label>
      <input type="number" v-model.lazy="weight" />(公斤)<br /><br />

      <label>病史：</label>
      <input type="text" v-model.lazy="history" /><br /><br />

      <button>诊断</button>
    </form>

    <p>患者 {{ name }} 的诊断结果：{{bMI}}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
        name: '',
        age: '',
        hight: '',
        weight: '',
        history: '',
        bMI:''
      
    }
  },
  methods: {
    fn() {
      this.bMI = this.weight/ (this.hight*this.hight)

      if (this.bMI <= 18.5) {
        this.bMI = '体重过轻'
      } else if(this.bMI >= 23.9) {
        this.bMI = '体重过轻'
      } else {
        this.bMI = '正常'

      }
      // console.log(this.bMI);
    },
  },
}
</script>
